<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>系统配置</title>
    <link rel="stylesheet" type="text/css" href="../js/jquery-easyui/themes/icon.css">
    <link rel="stylesheet" href="../js/jquery-easyui/themes/bootstrap/easyui.css">
    <script src="../js/jquery.min.js" type="text/javascript"></script>
    <script src="../js/jquery-easyui/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../js/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="../js/jquery-easyui/datagrid-detailview.js"></script>
    <script src="../js/jquery.form.js"></script>
    <script src="../js/jquery.serialize-object.js"></script>
    <script src="../../admin/js/uploadImg_first.js"></script>
    <script src="../../admin/js/uploadImg_informationPage.js"></script>
    <script src="../../admin/js/uploadImg_about_one.js"></script>
    <script src="../../admin/js/uploadImg_about_two.js"></script>
    <script src="../../admin/js/uploadImg_about_there.js"></script>
    <link rel="stylesheet" href="../css/uploadImg.css">
    <link rel="stylesheet" href="../css/uploadImg_informationPage.css">
</head>
<body style="padding: 0;margin: 0;position:relative;">
<div style="height:100%;width:100%;" class="easyui-layout" fit='true'>
    <div  region="center" style="width:100%" class="easyui-layout"   title="系统配置" border="false">
        <div region='north' id="tb" style="width: 30%; height: 45px;" >
            <table style="margin-left:10px;float:left;height:45px;width: 100%;" cellspacing="0" border="0" >
                <tr >
                    <td>
                        <!--<a href="#" class="easyui-linkbutton search" iconCls="icon-search" onclick="query()">查询</a>-->
                        <a href="#" class="easyui-linkbutton add" iconCls="icon-add" onclick="add()">重置首页轮转图片</a>
                        <a href="#" class="easyui-linkbutton add" iconCls="icon-add" onclick="add_informationPage()">重置资讯轮转图片</a>
                        <a href="#" class="easyui-linkbutton edit" iconCls="icon-edit" onclick="update_companyInfo()">修改公司信息</a>
                        <a href="#" class="easyui-linkbutton edit" iconCls="icon-edit" onclick="update_about()">修改关于信息</a>
                        <a href="#" class="easyui-linkbutton edit" iconCls="icon-edit" onclick="update_tree()">修改菜单</a>
                        <a href="#" class="easyui-linkbutton edit" iconCls="icon-edit" onclick="update_seo()">修改首页SEO信息</a>
                    </td>
                </tr>
            </table>
        </div>
        <table region='center' style="height: auto;max-height: 100%" id="listgrid" class='easyui-datagrid'  iconCls="icon-edit" toolbar="#tb"
               data-options="
               fit:true,
               rownumbers:true,
               singleSelect:true,
               fitColumns:true,
               showFooter:true,
               columns:[[
                {field:'id',title:'编码',width:50},
                {field:'loginInfo',title:'登录日志',width:450},
                {field:'createTime',title:'登录时间',width:100}
        ]]
        "></table>
    </div>
</div>


<!-- 添加首页轮转图 -->
<div id="add_dialog" class="easyui-dialog"  closed="true" modal="true" style="width: 600px; padding: 10px;">
    <form  id="upBox">
        <div id="inputBox">
            <input type="file" name="file" title="请选择图片" id="file" multiple="multiple" accept="image/png,image/jpg,image/gif,image/JPEG"/>选择图片
        </div>
        <div id="imgBox">
        </div>
        <a href="#" class="easyui-linkbutton ok" iconCls="icon-add" id="btn">上传</a>
    </form>
</div>

<!-- 添加资讯页轮转图 -->
<div id="add_dialog_informationPage" class="easyui-dialog"  closed="true" modal="true" style="width: 600px; padding: 10px;">
    <form  id="upBox_informationPage">
        <div id="inputBox_informationPage">
            <input type="file" name="file_informationPage" title="请选择图片" id="file_informationPage" multiple="multiple" accept="image/png,image/jpg,image/gif,image/JPEG"/>选择图片
        </div>
        <div id="imgBox_informationPage">
        </div>
        <a href="#" class="easyui-linkbutton ok" iconCls="icon-add" id="btn_informationPage">上传</a>
    </form>
</div>

<!-- 修改树显示 -->
<div id="edit_dialog_tree" class="easyui-dialog"  closed="true"
     modal="true" style="width: 450px; padding: 10px;">
        <div style="margin:20px 0;"></div>
        <div class="easyui-panel" style="padding:5px">
            <ul id="tt" class="easyui-tree"></ul>
            <script>
                $('#tt').tree({
                    url:'getTreeByJson',
                    animate: true,
                    onDblClick: function(node){
                        $(this).tree('beginEdit',node.target);
                    },
                    onAfterEdit:function(node) {
                        $.ajax({
                            type: "post",
                            url: "/editProductType",
                            data:{
                              id:node.id,
                              text:node.text
                            },
                            async: true,
                            success: function(data) {
                                data = JSON.parse(data);
                                console.log(data)
                                if(data.code == 1) {
                                    $.messager.show({
                                        title:'',
                                        msg:"修改成功",
                                        showType:'fade',
                                        timeout: 1500,
                                        style:{
                                            right:'',
                                            bottom:''
                                        }
                                    });
                                } else if(data.code == 9950) {
                                    $.messager.show({
                                        title:'',
                                        msg:"请补充英文标题",
                                        showType:'fade',
                                        timeout: 1500,
                                        style:{
                                            right:'',
                                            bottom:''
                                        }
                                    });
                                }
                            }
                        });
                    },

                    onContextMenu: function(e, node){
                        e.preventDefault();
                        // select the node
                        $('#tt').tree('select', node.target);
                        // display context menu
                        $('#mm').menu('show', {
                            left: e.pageX,
                            top: e.pageY
                        });
                    }
                });

                //添加节点
                function append() {
                    //var selected = $('#tt').tree('getSelected');
                    $.ajax({
                        type: "post",
                        url: "getMaxNode",
                        async: true,
                        success: function(data) {
                            var node = [{
                                id: data + 1,
                                text: 'temp'
                            }]
                            console.log(node)
                            $('#tt').tree('append', {
                                //parent: selected.target,
                                data: node
                            });
                            $.ajax({
                                type: "post",
                                url: "append",
                                data:{
                                    id:data + 1,
                                    text:'temp'
                                },
                                async: true,
                                success: function(data) {
                                    $.messager.show({
                                        title:'',
                                        msg:"添加成功",
                                        showType:'fade',
                                        timeout: 1500,
                                        style:{
                                            right:'',
                                            bottom:''
                                        }
                                    });
                                    $('#tt').tree('reload');
                                }
                            });
                        }
                    });
                }

                //删除节点
                function remove() {
                    var selected = $('#tt').tree('getSelected');
                    $.ajax({
                        type: "post",
                        url: "remove",
                        data:{
                            id:selected.id
                        },
                        async: true,
                        success: function(data) {
                            data = JSON.parse(data);
                            $.messager.show({
                                title:'',
                                msg:data.msg,
                                showType:'fade',
                                timeout: 1500,
                                style:{
                                    right:'',
                                    bottom:''
                                }
                            });
                            $('#tt').tree('reload');
                        }
                    });
                }
            </script>
            <div id="mm" class="easyui-menu" style="width:120px;">
                <div onclick="append()" data-options="iconCls:'icon-add'">添加</div>
                <div onclick="remove()" data-options="iconCls:'icon-remove'">删除</div>
            </div>
        </div>
</div>

<!-- 修改公司信息 -->
<div id="edit_dialog_companyBaseInfo" class="easyui-dialog"  closed="true"
     modal="true" style="width: 450px; padding: 10px;">
    <form id="edit_form_companyBaseInfo" method="post">
        <div style="margin-bottom:5px; margin-top: 20px">
            <input class="easyui-textbox"
                   name="companyName_zh" style="width: 100%;"
                   data-options="label:'公司名称（中文）:'">
        </div>
        <div style="margin-bottom:5px; margin-top: 20px">
            <input class="easyui-textbox"
                   name="companyName_en" style="width: 100%;"
                   data-options="label:'公司名称（英文）:'">
        </div>
        <div style="margin-bottom:5px; margin-top: 20px">
            <input class="easyui-textbox"
                   name="companyAddress" style="width: 100%;"
                   data-options="label:'公司地址:'">
        </div>
        <div style="margin-bottom:5px; margin-top: 20px">
            <input class="easyui-textbox"
                   name="companyTel" style="width: 100%;"
                   data-options="label:'公司电话:'">
        </div>
        <div style="margin-bottom:5px; margin-top: 20px">
            <input class="easyui-textbox"
                   name="latitude" style="width: 100%;"
                   data-options="label:'经度:'" >
        </div>
        <div style="margin-bottom:5px; margin-top: 20px">
            <input class="easyui-textbox"
                   name="longitude" style="width: 100%;"
                   data-options="label:'纬度:'" >
        </div>
    </form>
    <div style="text-align: center; padding-bottom: 10px;padding-top: 15px;">
        <a href="javascript:void(0)" class="easyui-linkbutton"
           style="width: 80px; height: 30px" onclick="updateSubmit()">提交</a>
    </div>
</div>

<!-- 修改首页seo信息 -->
<div id="edit_dialog_seo" class="easyui-dialog"  closed="true"
     modal="true" style="width: 450px; padding: 10px;">
    <form id="edit_form_seo" method="post">
        <div style="margin-bottom:5px; margin-top: 20px">
            <input class="easyui-textbox"
                   name="title" style="width: 100%;"
                   data-options="label:'seo标题:'">
        </div>
        <div style="margin-bottom:5px; margin-top: 20px">
            <input class="easyui-textbox"
                   name="keyword" style="width: 100%;"
                   data-options="label:'seo关键字:'">
        </div>
        <div style="margin-bottom:5px; margin-top: 20px">
            <input class="easyui-textbox"
                   name="descs" style="width: 100%;"
                   data-options="label:'seo描述:'" >
        </div>
    </form>
    <div style="text-align: center; padding-bottom: 10px;padding-top: 15px;">
        <a href="javascript:void(0)" class="easyui-linkbutton"
           style="width: 80px; height: 30px" onclick="updateSubmit_seo()">提交</a>
    </div>
</div>

<!-- 修改关于我们 -->
<div id="edit_dialog_about" class="easyui-dialog"  closed="true" modal="true" style="width: 450px; padding: 10px;">
    <form id="edit_form_about" method="post">
        <div>简介：</div>
        <div style="margin-bottom:5px; margin-top: 20px">
            <textarea name="info" style="width: 100%;height:60px"></textarea>
        </div>
        <div >
            <input type="text" id="shouRoomImg" name="shouRoomImg" placeholder="展厅图片"/><a href="#" class="easyui-linkbutton add" iconCls="icon-add" onclick="shouRoomImg()">上传图片</a>
        </div>
        <div >
            <input type="text" id="customers" name="customers" placeholder="客户图片" /><a href="#" class="easyui-linkbutton add" iconCls="icon-add" onclick="customers()">上传图片</a>
        </div>
        <div >
            <input type="text" id="defaultImage" name="defaultImage" placeholder="首页展厅图片" /><a href="#" class="easyui-linkbutton add" iconCls="icon-add" onclick="firstPageShowRoom()">上传图片</a>
        </div>
    </form>
    <div style="text-align: center; padding-bottom: 10px;padding-top: 15px;">
        <a href="javascript:void(0)" class="easyui-linkbutton"
           style="width: 80px; height: 30px" onclick="updateSubmit_about()">提交</a>
    </div>
</div>
<!-- 添加展厅图片 -->
<div id="add_dialog_shouRoomImg" class="easyui-dialog"  closed="true" modal="true" style="width: 600px; padding: 10px;">
    <form  id="upBox_shouRoomImg" method="post" action="upImage">
        <div id="inputBox_shouRoomImg">
            <input type="file" name="file_shouRoomImg" title="请选择图片" id="file_shouRoomImg" multiple="multiple" accept="image/png,image/jpg,image/gif,image/JPEG"/>选择图片
        </div>
        <div id="imgBox_shouRoomImg">
        </div>
        <a href="#" class="easyui-linkbutton ok" iconCls="icon-add" id="btn_shouRoomImg">上传</a>
    </form>
</div>
<script>
    function shouRoomImg(){
        $("#imgBox_shouRoomImg").html("");
        $("#add_dialog_shouRoomImg").dialog("open").dialog("center").dialog("setTitle", "上传图片");
    }
    imgUpload_shouRoomImg({
        inputId:'file_shouRoomImg', //input框id
        imgBox:'imgBox_shouRoomImg', //图片容器id
        buttonId:'btn_shouRoomImg', //提交按钮id
        upUrl:'/upImage',  //提交地址
        data:'image', //参数名
        num:"1"//最多上传图片个数
    })
</script>
<!-- 添加客户图片 -->
<div id="add_dialog_customers" class="easyui-dialog"  closed="true" modal="true" style="width: 600px; padding: 10px;">
    <form  id="upBox_customers" method="post" action="upImage">
        <div id="inputBox_customers">
            <input type="file" name="file_customers" title="请选择图片" id="file_customers" multiple="multiple" accept="image/png,image/jpg,image/gif,image/JPEG"/>选择图片
        </div>
        <div id="imgBox_customers">
        </div>
        <a href="#" class="easyui-linkbutton ok" iconCls="icon-add" id="btn_customers">上传</a>
    </form>
</div>
<script>
    imgUpload_customers({
        inputId:'file_customers', //input框id
        imgBox:'imgBox_customers', //图片容器id
        buttonId:'btn_customers', //提交按钮id
        upUrl:'/upImage',  //提交地址
        data:'image', //参数名
        num:"1"//最多上传图片个数
    })
    function customers(){
        $("#imgBox_customers").html("");
        $("#add_dialog_customers").dialog("open").dialog("center").dialog("setTitle", "上传图片");
    }
</script>
<!-- 添加首页展厅图片 -->
<div id="add_dialog_firstPageShowRoom" class="easyui-dialog"  closed="true" modal="true" style="width: 600px; padding: 10px;">
    <form  id="upBox_firstPageShowRoom" method="post" action="upImage">
        <div id="inputBox_firstPageShowRoom">
            <input type="file" name="file_firstPageShowRoom" title="请选择图片" id="file_firstPageShowRoom" multiple="multiple" accept="image/png,image/jpg,image/gif,image/JPEG"/>选择图片
        </div>
        <div id="imgBox_firstPageShowRoom">
        </div>
        <a href="#" class="easyui-linkbutton ok" iconCls="icon-add" id="btn_firstPageShowRoom">上传</a>
    </form>
</div>
<script>
    imgUpload_firstPageShowRoom({
        inputId:'file_firstPageShowRoom', //input框id
        imgBox:'imgBox_firstPageShowRoom', //图片容器id
        buttonId:'btn_firstPageShowRoom', //提交按钮id
        upUrl:'/upImage',  //提交地址
        data:'image', //参数名
        num:"1"//最多上传图片个数
    })

    function firstPageShowRoom(){
        $("#imgBox_firstPageShowRoom").html("");
        $("#add_dialog_firstPageShowRoom").dialog("open").dialog("center").dialog("setTitle", "上传图片");
    }
</script>

<script type="text/javascript">
    $(function () {
        $("#listgrid").datagrid('options').url= '/getLoginLog';
        $('#listgrid').datagrid('load');
    });

    //  查找
    function query(){
        $('#listgrid').datagrid('reload');
    }

    //重置首页轮转图
    function add(){
        $("#imgBox").html("");
        $("#add_dialog").dialog("open").dialog("center").dialog("setTitle", "上传图片");
    }

    //重置资讯页轮转图
    function add_informationPage(){
        $("#imgBox_informationPage").html("");
        $("#add_dialog_informationPage").dialog("open").dialog("center").dialog("setTitle", "上传图片");
    }

    //打开seo信息
    function update_seo() {
        $.ajax({
            type: "post",
            url: "getAboutInfo",
            async: true,
            //下面这两个要写成false，要不然上传不了。
            processData: false,
            contentType: false,
            success: function(data) {
                data = JSON.parse(data);
                console.log(data);
                data = JSON.parse(data.data);
                console.log(data);
                //data = data.data;
                //data = JSON.parse(data);

            }
        });
        $("#edit_dialog_seo").dialog("open").dialog("center").dialog("setTitle", "修改");
    }

    //打开关于信息
    function update_tree() {
        //$("#edit_form_tree").form("load", data);
        $("#edit_dialog_tree").dialog("open").dialog("center").dialog("setTitle", "修改");
    }

    //打开关于信息
    function update_about() {
        $.ajax({
            type: "post",
            url: "getAboutInfo",
            async: true,
            //下面这两个要写成false，要不然上传不了。
            processData: false,
            contentType: false,
            success: function(data) {
                data = JSON.parse(data);
                //data = data.data;
                //data = JSON.parse(data);
                $("#edit_form_about").form("load", data);
                $("#edit_dialog_about").dialog("open").dialog("center").dialog("setTitle", "修改");
            }
        });
    }

    //打开公司信息
    function update_companyInfo() {
        $.ajax({
            type: "post",
            url: "getCompanyInfo",
            async: true,
            //下面这两个要写成false，要不然上传不了。
            processData: false,
            contentType: false,
            success: function(data) {
                data = JSON.parse(data);
                data = data.data;
                data = JSON.parse(data);
                console.log(data)
                $("#edit_form_companyBaseInfo").form("load", data);
                $("#edit_dialog_companyBaseInfo").dialog("open").dialog("center").dialog("setTitle", "修改");
            }
        });
    }

    //修改seo信息
    function updateSubmit_seo(){
        $.messager.progress();
        $('#edit_form_seo').form(
            'submit',{
                url:"/changeSeo",
                onSubmit:function(){
                    var isValid = $(this).form('validate');
                    if (!isValid){
                        $.messager.progress('close');
                    }
                    return isValid;
                },
                success:function(result){
                    $.messager.progress('close');
                    $.messager.show({
                        title:'',
                        msg:result,
                        showType:'fade',
                        timeout: 1500,
                        style:{
                            right:'',
                            bottom:''
                        }
                    });
                    $('#edit_dialog_seo').dialog('close');
                    //$("#listgrid").datagrid("reload");
                }
            });
    }

    //修改提交
    function updateSubmit(){
        $.messager.progress();
        $('#edit_form_companyBaseInfo').form(
            'submit',{
                url:"/changeCompanyInfo",
                onSubmit:function(){
                    var isValid = $(this).form('validate');
                    if (!isValid){
                        $.messager.progress('close');
                    }
                    return isValid;
                },
                success:function(result){
                    $.messager.progress('close');
                    $.messager.show({
                        title:'',
                        msg:result,
                        showType:'fade',
                        timeout: 1500,
                        style:{
                            right:'',
                            bottom:''
                        }
                    });
                    $('#edit_dialog_companyBaseInfo').dialog('close');
                    //$("#listgrid").datagrid("reload");
                }
            });
    }

    //修改提交关于信息
    function updateSubmit_about(){
        $.messager.progress();
        $('#edit_form_about').form(
            'submit',{
                url:"/changeAboutInfo",
                onSubmit:function(){
                    var isValid = $(this).form('validate');
                    if (!isValid){
                        $.messager.progress('close');
                    }
                    return isValid;
                },
                success:function(result){
                    $.messager.progress('close');
                    $.messager.show({
                        title:'',
                        msg:result,
                        showType:'fade',
                        timeout: 1500,
                        style:{
                            right:'',
                            bottom:''
                        }
                    });
                    $('#edit_dialog_about').dialog('close');
                    //$("#listgrid").datagrid("reload");
                }
            });
    }

    imgUpload_informationPage({
        inputId:'file_informationPage', //input框id
        imgBox:'imgBox_informationPage', //图片容器id
        buttonId:'btn_informationPage', //提交按钮id
        upUrl:'/setInformationBanner',  //提交地址
        data:'image', //参数名
        num:"5"//最多上传图片个数
    })

    imgUpload_first({
        inputId:'file', //input框id
        imgBox:'imgBox', //图片容器id
        buttonId:'btn', //提交按钮id
        upUrl:'/setBanner',  //提交地址
        data:'image', //参数名
        num:"5"//最多上传图片个数
    })

</script>

</body>
</html>